<?php
	include("includes/secure.php");
	include("includes/config.php");
	include("includes/class/client.class.php");
	
	$client = new Client();

	if( isset($_POST['add']) && $_POST['add'] == 1 ){
		$data->bus_name = trim(mysql_real_escape_string($_POST['bus_name']));		
		
		if ( $bus_code = $client->addBusinessType($data) ) { 
			$businessTypeList = $client->businessTypeList();
			$countBusinessTypeList = count ($businessTypeList);
			
			$html = '<select name="bus_code" id="bus_code" class="text_grv" onchange="javascript: chargeBusinessType(this.value);">';
			$html .= '<option value="" selected="selected" disabled="disabled">Select..</option>';
			for($i=0; $i < $countBusinessTypeList; $i++) {
				if ( $businessTypeList[$i]->bus_code == $bus_code )
					$selected = 'selected';
				else
					$selected = '';
				$html .= '<option value="'.$businessTypeList[$i]->bus_code.'" '.$selected.'>'.$businessTypeList[$i]->bus_name.'</option>';
			}
			$html .= '<option value="-1">Other</option>';
			$html .= '</select>';
			echo ("<script> parent.reloadBusiness('".$html."')</script>");
		}else
			echo "<script> parent.showCoolMessage('It could not be added the Business Type.', 1) </script>";	
	}
?>